#pragma once 

#include <Sprite2D.hpp>
#include <Convert.hpp>

class TWater2D : public TSprite2D
{
	typedef TSprite2D Base;
public:
	TWater2D(IDK::Core core)
	{
		ref<IDK::IMaterial> mtrl = core->GetMaterial("Water_mtrl");
		mtrl->SetBlendMode(IDK::IRenderState::Blend::AlphaBlend);

		ref<IDK::IShader> shader = core->GetShader("Water");

		shader->AddParameter(IDK::IShaderParameter::Type::VertexAttribute,
			IDK::IShaderParameter::Declaration::VertexPosition, "Vertex"); 

		shader->AddParameter(IDK::IShaderParameter::Type::ConstantParameter, 
			IDK::IShaderParameter::Declaration::MatrixProjection, "inProj"); 

		shader->AddParameter(IDK::IShaderParameter::Type::ConstantParameter, 
			IDK::IShaderParameter::Declaration::MatrixView, "inView");

		shader->AddParameter(IDK::IShaderParameter::Type::ConstantParameter,
			IDK::IShaderParameter::Declaration::Texture0, "inSample0"); 

		shader->AddParameter(IDK::IShaderParameter::Type::ConstantParameter, 
			IDK::IShaderParameter::Declaration::TimeElapsed, "inTime");

		
		IDK::Texture texture = core->AddTexture("water_noise/decal", IDK::Pixel::Type::RGBA_PVR4, 1, 512, 512);

		mtrl->SetTexture(IDK::IMaterial::TextureMode::Sampler0, texture);

		mtrl->SetShader(shader);

		SetMaterial(mtrl);
	}

	virtual bool Render(IDK::IRenderState& rndState)
	{
		return Base::Render(rndState);
	}
};

typedef ref<TWater2D> Water2D;